home *** CD-ROM | disk | FTP | other *** search
- Path: news.tamu.edu!tam2000!jrm4227
- From: jrm4227@tam2000.tamu.edu (Justin Ray Mcelhanon)
- Newsgroups: comp.lang.c,comp.unix.programmer,comp.unix.questions
- Subject: Correct usage of system call?
- Date: 27 Mar 1996 09:00:47 GMT
- Organization: Texas A&M University, College Station, TX
- Message-ID: <4jb03v$oi6@news.tamu.edu>
- NNTP-Posting-Host: tam2000.tamu.edu
- X-Newsreader: TIN [version 1.2 PL2]
-
- Alright here is the situation I need help with, can not figure out the
- problem after at least three hours of trying to fix it. I have written a small
- c code that is a menu that calls up unix commands using sytems:
-
- i.e)
- printf ("1. Pine");
- printf ("2. Usenet (tin)\n");
- printf ("3. Ftp\n");
-
- scanf("%d", &choice);
-
- switch (choice)
- {
- case 1:
- printf ("Executing Pine\n");
- system("pine");
- break;
-
-
- It works great, however, I'd like to add in a command to allow one to
- type in the site name. Example, when you call up the ftp case it does
- a scanf(%s,site); (with site declared as an char string) anyway I then
- want to take that and put it in the system command. ie system("ftp site"),
- but that is not the proper syntax, how could I accomplish this? That will
- not work, I tested to see if the system command would even accept variables
- as input, so I tried system(&site); ( BTW system(site) kept giving segmentation
- faults) this code would properly send the output to unix shell, however, if
- a space is place in the string it only reads the first part, and it also
- doesn't include ftp on the front. What is the proper syntax to mix C
- variables and unix system calls? Mind you I've taught the little C and unix
- I know from these news groups and such, so if something appears totally
- wrong, it might be :) If you'd like a better explination of the problem,
- or want more of the code, email me at thorin@tamu.edu, and if you reply,
- please Carbon Copy me a response via mail because I don't trust the usenet
- server, it plays Ollie North and cannot recall that post or reply. Okay
- thanks for the help
-
-
- --
- ****************************************** A! JW2 WAR+++ PI++ BR+++ SL+++ SK+
- Yakko: "Well it's been fun friend, R&R++ GDF++ GP+++++ B&M++ HIP- SN+
- but we've got to get back to HN+++! MS+ ME+ CB~ MM++! KK-- CO++
- planet reality now" (Baloney and Friends) GLF-- P++ $++ E26 Ee10 TSlappy A18
- Justin McElhanon----------thorin@tamu.edu
- ******************************************
-